#ifndef __BUOLA_GUI_CSIMPLEAPP_H__
#define __BUOLA_GUI_CSIMPLEAPP_H__

#include <buola/gui.h>
#include <buola/app/capp.h>
#include <buola/gui/cwindow.h>

namespace buola { namespace gui {

///\addtogroup gui
///@{

/////////////////////////////////////////////////////////////////////////////

/// simple application

/// Use it for simple applications where it's not necessary to derive from
/// CApp for custom functionality
///
/////////////////////////////////////////////////////////////////////////////

template<typename tWindow>
class CSimpleApp : public CApp
{
public:
//! \name constructor and destructor
//@{
    template<typename... tArgs>
    CSimpleApp(tArgs&&... pArgs)
        :   mWindow(new tWindow(std::forward<tArgs>(pArgs)...))
    {
    }

    ~CSimpleApp()
    {
    }
//@}

private:
    //! creates the main window
    virtual bool Start()
    {
        mWindow->Map(CSize_d(800,600));
        set_main_window(mWindow);
        mWindow->Show();

        return true;
    }

    virtual void Finish()
    {
//      delete mWindow;
    }

    intrusive_ptr<tWindow> mWindow; //!< the main window
};

///@}

/*namespace gui*/ } /*namespace buola*/ }

#endif
